<!DOCTYPE HTML>
<html lang="en" class="sidebar-visible no-js light">
    <head>
        <!-- Book generated using mdBook -->
        <meta charset="UTF-8">
        <title>伤害排行榜</title>
                

        <!-- Custom HTML head -->
        

        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="theme-color" content="#ffffff" />

                <link rel="icon" href="../favicon.svg">
                        <link rel="shortcut icon" href="../favicon.png">
                <link rel="stylesheet" href="../css/variables.css">
        <link rel="stylesheet" href="../css/general.css">
        <link rel="stylesheet" href="../css/chrome.css">
                <link rel="stylesheet" href="../css/print.css" media="print">
        
        <!-- Fonts -->
        <link rel="stylesheet" href="../FontAwesome/css/font-awesome.css">
                <link rel="stylesheet" href="../fonts/fonts.css">
        
        <!-- Highlight.js Stylesheets -->
        <link rel="stylesheet" href="../highlight.css">
        <link rel="stylesheet" href="../tomorrow-night.css">
        <link rel="stylesheet" href="../ayu-highlight.css">

        <!-- Custom theme stylesheets -->
        
            </head>
    <body>
        <!-- Provide site root to javascript -->
        <script type="text/javascript">
            var path_to_root = "../";
            var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "navy" : "light";
        </script>

        <!-- Work around some values being stored in localStorage wrapped in quotes -->
        <script type="text/javascript">
            try {
                var theme = localStorage.getItem('mdbook-theme');
                var sidebar = localStorage.getItem('mdbook-sidebar');

                if (theme.startsWith('"') && theme.endsWith('"')) {
                    localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
                }

                if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
                    localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
                }
            } catch (e) { }
        </script>

        <!-- Set the theme before any content is loaded, prevents flash -->
        <script type="text/javascript">
            var theme;
            try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
            if (theme === null || theme === undefined) { theme = default_theme; }
            var html = document.querySelector('html');
            html.classList.remove('no-js')
            html.classList.remove('light')
            html.classList.add(theme);
            html.classList.add('js');
        </script>

        <!-- Hide / unhide sidebar before it is displayed -->
        <script type="text/javascript">
            var html = document.querySelector('html');
            var sidebar = 'hidden';
            if (document.body.clientWidth >= 1080) {
                try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
                sidebar = sidebar || 'visible';
            }
            html.classList.remove('sidebar-visible');
            html.classList.add("sidebar-" + sidebar);
        </script>

        <nav id="sidebar" class="sidebar" aria-label="Table of contents">
            <div class="sidebar-scrollbox">
                <ol class="chapter"><li class="chapter-item expanded "><a href="../index.html"><strong aria-hidden="true">1.</strong> 快速开始</a></li><li class="chapter-item expanded "><a href="../quick/struct.html"><strong aria-hidden="true">2.</strong> 项目结构</a></li><li class="chapter-item expanded "><a href="../quick/command.html"><strong aria-hidden="true">3.</strong> SDK命令指引</a></li><li class="chapter-item expanded "><a href="../quick/update.html"><strong aria-hidden="true">4.</strong> 更新日志</a></li><li class="chapter-item expanded "><div><strong aria-hidden="true">5.</strong> 功能库</div></li><li><ol class="section"><li class="chapter-item expanded "><a href="../lib/api.html"><strong aria-hidden="true">5.1.</strong> API</a></li><li class="chapter-item expanded "><a href="../lib/attr.html"><strong aria-hidden="true">5.2.</strong> 属性 Attr</a></li><li class="chapter-item expanded "><a href="../lib/japi.html"><strong aria-hidden="true">5.3.</strong> JAPI</a></li><li class="chapter-item expanded "><a href="../lib/hslk1.html"><strong aria-hidden="true">5.4.</strong> Slk入门</a></li><li class="chapter-item expanded "><a href="../lib/hslk2.html"><strong aria-hidden="true">5.5.</strong> Slk进阶</a></li><li class="chapter-item expanded "><a href="../lib/hslk_f6.html"><strong aria-hidden="true">5.6.</strong> Slk原生物编字段</a></li><li class="chapter-item expanded "><a href="../lib/hslk_misc.html"><strong aria-hidden="true">5.7.</strong> Slk与MISC数据</a></li><li class="chapter-item expanded "><a href="../lib/sync.html"><strong aria-hidden="true">5.8.</strong> Sync同步</a></li></ol></li><li class="chapter-item expanded "><div><strong aria-hidden="true">6.</strong> 例子</div></li><li><ol class="section"><li class="chapter-item expanded "><a href="../example/leaderBoard.html"><strong aria-hidden="true">6.1.</strong> 使用排行榜</a></li><li class="chapter-item expanded "><a href="../example/multiBoard.html"><strong aria-hidden="true">6.2.</strong> 使用多面板</a></li><li class="chapter-item expanded "><a href="../example/dialog.html"><strong aria-hidden="true">6.3.</strong> 难度选择对话框</a></li><li class="chapter-item expanded "><a href="../example/pickHero.html"><strong aria-hidden="true">6.4.</strong> 常见两种选英雄</a></li><li class="chapter-item expanded "><a href="../example/attack.html"><strong aria-hidden="true">6.5.</strong> 简单刷兵</a></li></ol></li><li class="chapter-item expanded "><div><strong aria-hidden="true">7.</strong> 其他学习</div></li><li><ol class="section"><li class="chapter-item expanded "><a href="../other/jetbrain.html"><strong aria-hidden="true">7.1.</strong> Jetbrain设置</a></li><li class="chapter-item expanded "><a href="../other/q_a.html"><strong aria-hidden="true">7.2.</strong> 询问的技巧</a></li><li class="chapter-item expanded "><a href="../other/dz.html"><strong aria-hidden="true">7.3.</strong> 平台上线须知</a></li><li class="chapter-item expanded "><a href="../other/war3_tec.html"><strong aria-hidden="true">7.4.</strong> 魔兽作图小技巧</a></li><li class="chapter-item expanded "><a href="../other/war3_terrainArt.html"><strong aria-hidden="true">7.5.</strong> 魔兽地形贴图路径</a></li><li class="chapter-item expanded "><a href="../other/lua_engine.html"><strong aria-hidden="true">7.6.</strong> YDLua引擎</a></li><li class="chapter-item expanded "><a href="../other/ui_fdf.html"><strong aria-hidden="true">7.7.</strong> UI &amp; FDF</a></li></ol></li><li class="chapter-item expanded "><div><strong aria-hidden="true">8.</strong> 小小专栏</div></li><li><ol class="section"><li class="chapter-item expanded "><a href="../xxqq/BV1nV411J7FB.html"><strong aria-hidden="true">8.1.</strong> 基础指令介绍</a></li><li class="chapter-item expanded "><a href="../xxqq/BV1TK4y1Z7eB.html"><strong aria-hidden="true">8.2.</strong> hslk高级用法演示1</a></li><li class="chapter-item expanded "><a href="../xxqq/BV1M64y117sB.html"><strong aria-hidden="true">8.3.</strong> hslk高级用法演示2</a></li><li class="chapter-item expanded "><a href="../xxqq/BV1ZV411J7JJ.html"><strong aria-hidden="true">8.4.</strong> hslk高级用法演示3</a></li><li class="chapter-item expanded "><a href="../xxqq/BV1iv411L7CP.html"><strong aria-hidden="true">8.5.</strong> UI之sync演示</a></li><li class="chapter-item expanded "><a href="../xxqq/BV1Hy4y1s7cj.html"><strong aria-hidden="true">8.6.</strong> 构建酒馆与小地图UI显示头像</a></li><li class="chapter-item expanded "><a href="../xxqq/BV1Lh411v7pR.html" class="active"><strong aria-hidden="true">8.7.</strong> 伤害排行榜</a></li><li class="chapter-item expanded "><a href="../xxqq/upscale.html"><strong aria-hidden="true">8.8.</strong> 高端演示</a></li></ol></li></ol>            </div>
            <div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
        </nav>

        <div id="page-wrapper" class="page-wrapper">

            <div class="page">
                
                <div id="menu-bar-hover-placeholder"></div>
                <div id="menu-bar" class="menu-bar sticky bordered">
                    <div class="left-buttons">
                        <button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
                            <i class="fa fa-bars"></i>
                        </button>
                        <button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
                            <i class="fa fa-paint-brush"></i>
                        </button>
                        <ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
                            <li role="none"><button role="menuitem" class="theme" id="light">Light (default)</button></li>
                            <li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
                            <li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
                            <li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
                            <li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
                        </ul>
                                                <button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
                            <i class="fa fa-search"></i>
                        </button>
                                            </div>

                    <h1 class="menu-title"></h1>

                    <div class="right-buttons">
                                                <a href="../print.html" title="Print this book" aria-label="Print this book">
                            <i id="print-button" class="fa fa-print"></i>
                        </a>
                                                                        
                    </div>
                </div>

                                <div id="search-wrapper" class="hidden">
                    <form id="searchbar-outer" class="searchbar-outer">
                        <input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
                    </form>
                    <div id="searchresults-outer" class="searchresults-outer hidden">
                        <div id="searchresults-header" class="searchresults-header"></div>
                        <ul id="searchresults">
                        </ul>
                    </div>
                </div>
                
                <!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
                <script type="text/javascript">
                    document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
                    document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
                    Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
                        link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
                    });
                </script>

                <div id="content" class="content">
                    <main>
                        <h2 id="小小演示"><a class="header" href="#小小演示">小小演示</a></h2>
<h3 id="伤害排行榜"><a class="header" href="#伤害排行榜">伤害排行榜</a></h3>
<p>B站演示</p>
<blockquote>
<p><a target="_blank" href="https://www.bilibili.com/video/BV1Lh411v7pR">魔兽争霸伤害排行榜</a></p>
</blockquote>
<p>伤害排行榜UI显示</p>
<pre><code class="language-lua">UI = function()
    --加载toc
    hdzui.loadToc(&quot;UI\\frame.toc&quot;)
    --初始化
    awar = hdzui.frame(&quot;awar&quot;,hdzui.origin.game(),0)
    --设置位置
    hjapi.DzFrameSetAbsolutePoint(awar,4,0.388,0.350)
    hjapi.DzFrameShow(awar,false)

    --伤害榜初始化
    damUI = {}
    txtUI = {}
    barUI = {}
    --logo
    damUI[1] = hdzui.frameTag(&quot;BACKDROP&quot;,&quot;x1&quot;,hdzui.origin.game(),&quot;&quot;)
    hjapi.DzFrameSetTexture(damUI[1],&quot;war3mapImported\\dam.tga&quot;,false)
    hjapi.DzFrameSetAbsolutePoint(damUI[1],4,0.744,0.411)
    hjapi.DzFrameSetSize(damUI[1],0.108,0.026)
    hjapi.DzFrameShow(damUI[1],true)
    --忘记放我可爱的音乐了
    hplayer.forEach(function(enumPlayer, idx)
        --头像
        damUI[idx + 1] = hdzui.frameTag(&quot;BACKDROP&quot;,&quot;tx1&quot; .. idx,hdzui.origin.game(),&quot;&quot;)
        hjapi.DzFrameSetTexture(damUI[idx + 1],&quot;war3mapImported\\tx.tga&quot;,false)
        hjapi.DzFrameSetPoint(damUI[idx + 1],2,damUI[1],8,0,0)
        hjapi.DzFrameSetSize(damUI[idx + 1],0.015,0.019)
        hjapi.DzFrameShow(damUI[idx + 1],false)

        --条条
        barUI[idx] = hdzui.frameTag(&quot;BACKDROP&quot;,&quot;txx&quot; .. idx,damUI[idx + 1],&quot;&quot;)
        hjapi.DzFrameSetTexture(barUI[idx],&quot;war3mapImported\\green.tga&quot;,false)
        hjapi.DzFrameSetPoint(barUI[idx],5,damUI[idx + 1],3,0,0)
        hjapi.DzFrameSetSize(barUI[idx],0.107,0.019)
        hjapi.DzFrameShow(barUI[idx],true)

        --伤害文字
        txtUI[idx] = hdzui.frameTag(&quot;TEXT&quot;,&quot;tx&quot; .. idx,damUI[idx + 1],&quot;&quot;)
        hjapi.DzFrameSetText(txtUI[idx],&quot;0&quot;)
        hjapi.DzFrameSetPoint(txtUI[idx],5,barUI[idx],3,0,0)
        hjapi.DzFrameSetSize(txtUI[idx],0.030,0.017)
        hjapi.DzFrameShow(txtUI[idx],true)
    end)
    --注册3个按钮点击事件
    hsync.onFrameMouse(hjapi.DzFrameFindByName(&quot;awar_1&quot;,0),1,function(syncData)
        --添加技能
        hskill.add(hero[syncData.triggerPlayer],tb[syncData.triggerPlayer][1],1)
        if (syncData.triggerPlayer ~= hplayer.loc()) then
            return
        end
        hjapi.DzFrameShow(awar,false)
    end)
    hsync.onFrameMouse(hjapi.DzFrameFindByName(&quot;awar_2&quot;,0),1,function(syncData)
        --添加技能
        hskill.add(hero[syncData.triggerPlayer],tb[syncData.triggerPlayer][2],1)
        if (syncData.triggerPlayer ~= hplayer.loc()) then
            return
        end
        hjapi.DzFrameShow(awar,false)
    end)
    hsync.onFrameMouse(hjapi.DzFrameFindByName(&quot;awar_3&quot;,0),1,function(syncData)
        --添加技能
        hskill.add(hero[syncData.triggerPlayer],tb[syncData.triggerPlayer][3],1)
        if (syncData.triggerPlayer ~= hplayer.loc()) then
            return
        end
        hjapi.DzFrameShow(awar,false)
    end)

    --然后计时器改变UI位置

    htime.setInterval(0.05,function(curTimer)
        local sort = {}
        hplayer.forEach(function(enumPlayer, idx)
            local s = {idx = idx , val = hplayer.getDamage(enumPlayer)}
            table.insert(sort,s)
        end)
        --排序
        table.sort(sort,function(a, b)
            if (a.val == b.val) then
                return b.idx &gt; a.idx
            end
            return a.val &gt; b.val
        end)
        --根据排序更改头像UI位置
        local dam = sort[1].val
        local i = 0
        for k,v in ipairs(sort)do
            if (k &gt; 1) then
                --除了排第一的 其他条条根据第一名伤害来确定大小
                i = v.val / dam
                hjapi.DzFrameSetSize(barUI[v.idx],i * 0.107,0.019)
            else
                hjapi.DzFrameSetSize(barUI[v.idx],0.107,0.019)
            end
            --修改伤害文字
            hjapi.DzFrameSetText(txtUI[v.idx],math.round(hplayer.getDamage(hplayer.players[v.idx])))
            --修改头像图标
            hjapi.DzFrameSetTexture(damUI[v.idx + 1],hslk.i2v(hunit.getId(hero[v.idx]),&quot;slk&quot;,&quot;Art&quot;),false)
            --修改头像UI位置
            hjapi.DzFrameSetPoint(damUI[v.idx + 1],2,damUI[1],8,0,(k - 1) * -0.02)
            hjapi.DzFrameShow(damUI[v.idx + 1],true)
        end
    end)
end
</code></pre>

                    </main>

                    <nav class="nav-wrapper" aria-label="Page navigation">
                        <!-- Mobile navigation buttons -->
                                                    <a rel="prev" href="../xxqq/BV1Hy4y1s7cj.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
                                <i class="fa fa-angle-left"></i>
                            </a>
                        
                                                    <a rel="next" href="../xxqq/upscale.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
                                <i class="fa fa-angle-right"></i>
                            </a>
                        
                        <div style="clear: both"></div>
                    </nav>
                </div>
            </div>

            <nav class="nav-wide-wrapper" aria-label="Page navigation">
                                    <a rel="prev" href="../xxqq/BV1Hy4y1s7cj.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
                        <i class="fa fa-angle-left"></i>
                    </a>
                
                                    <a rel="next" href="../xxqq/upscale.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
                        <i class="fa fa-angle-right"></i>
                    </a>
                            </nav>

        </div>

                <!-- Livereload script (if served using the cli tool) -->
        <script type="text/javascript">
            var socket = new WebSocket("ws://localhost:3000/__livereload");
            socket.onmessage = function (event) {
                if (event.data === "reload") {
                    socket.close();
                    location.reload();
                }
            };

            window.onbeforeunload = function() {
                socket.close();
            }
        </script>
        
        
        
                <script type="text/javascript">
            window.playground_copyable = true;
        </script>
        
        
                <script src="../elasticlunr.min.js" type="text/javascript" charset="utf-8"></script>
        <script src="../mark.min.js" type="text/javascript" charset="utf-8"></script>
        <script src="../searcher.js" type="text/javascript" charset="utf-8"></script>
        
        <script src="../clipboard.min.js" type="text/javascript" charset="utf-8"></script>
        <script src="../highlight.js" type="text/javascript" charset="utf-8"></script>
        <script src="../book.js" type="text/javascript" charset="utf-8"></script>

        <!-- Custom JS scripts -->
        
        
    </body>
</html>
